package flc.ast.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.CenterBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.basic.view.container.StkRelativeLayout;
import stark.common.bean.StkResBean;

public class WallpaperTabAdapter extends StkProviderMultiAdapter<StkResBean> {

    public WallpaperTabAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(150));
        addItemProvider(new WallpaperTabProvider());
    }


    private class WallpaperTabProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_wallpaper_tab;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            Glide.with(getContext()).load(bean.getUrl())
                    .into((ImageView) baseViewHolder.getView(R.id.ivWallpaperTabItemImg));
            if (baseViewHolder.getBindingAdapterPosition()==0){
                StkRelativeLayout view=baseViewHolder.getView(R.id.rlWallpaperTabItem);
                ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(view.getLayoutParams());
                params.setMargins(100,0,20,0);
                view.setLayoutParams(params);
            }
            if (baseViewHolder.getBindingAdapterPosition()==2){
                baseViewHolder.getView(R.id.rlWallpaperTabItemMore).setVisibility(View.VISIBLE);
            }else {
                baseViewHolder.getView(R.id.rlWallpaperTabItemMore).setVisibility(View.GONE);
            }
        }
    }
}
